#include <iostream>
#include <boost/lexical_cast.hpp>

using std::cout;
using std::endl;
using std::string;

string
dec_to_hex(string in)
{
    int x = boost::lexical_cast<int>(in);

    if (x == 0)
    {
        return "0";
    }

    string out = "";

    while (x > 0)
    {
        switch(x % 16) {
        case 0  : out = "0" + out; break;
        case 1  : out = "1" + out; break;
        case 2  : out = "2" + out; break;
        case 3  : out = "3" + out; break;
        case 4  : out = "4" + out; break;
        case 5  : out = "5" + out; break;
        case 6  : out = "6" + out; break;
        case 7  : out = "7" + out; break;
        case 8  : out = "8" + out; break;
        case 9  : out = "9" + out; break;
        case 10 : out = "A" + out; break;
        case 11 : out = "B" + out; break;
        case 12 : out = "C" + out; break;
        case 13 : out = "D" + out; break;
        case 14 : out = "E" + out; break;
        case 15 : out = "F" + out; break;
        };

        x /= 16;
    }

    return out;
}

int
main(int argc, char **argv)
{
    cout << dec_to_hex("0") << endl;
    cout << dec_to_hex("1") << endl;
    cout << dec_to_hex("2") << endl;
    cout << dec_to_hex("3") << endl;
    cout << dec_to_hex("4") << endl;
    cout << dec_to_hex("5") << endl;
    cout << dec_to_hex("6") << endl;
    cout << dec_to_hex("7") << endl;
    cout << dec_to_hex("8") << endl;
    cout << dec_to_hex("9") << endl;
    cout << dec_to_hex("10") << endl;
    cout << dec_to_hex("11") << endl;
    cout << dec_to_hex("12") << endl;
    cout << dec_to_hex("13") << endl;
    cout << dec_to_hex("14") << endl;
    cout << dec_to_hex("15") << endl;
    cout << dec_to_hex("16") << endl;
    cout << dec_to_hex("17") << endl;
    cout << dec_to_hex("18") << endl;
    cout << dec_to_hex("19") << endl;
    cout << dec_to_hex("20") << endl;
    cout << dec_to_hex("21") << endl;
    cout << dec_to_hex("22") << endl;
    cout << dec_to_hex("23") << endl;
    cout << dec_to_hex("24") << endl;
    cout << dec_to_hex("24") << endl;
    cout << dec_to_hex("25") << endl;
    cout << dec_to_hex("26") << endl;
    cout << dec_to_hex("27") << endl;
    cout << dec_to_hex("28") << endl;
    cout << dec_to_hex("29") << endl;
    cout << dec_to_hex("30") << endl;
    cout << dec_to_hex("31") << endl;
    cout << dec_to_hex("32") << endl;
}
